package com.archgeek.spark.examples.v20210108

import org.apache.spark.{SparkConf, SparkContext}

/**
 *
 * @author pizhihui
 * @date 2021-01-08
 */
object SparkDemo {

  def main(args: Array[String]): Unit = {

    val conf = new SparkConf().setMaster("local").setAppName("test")
    val sc = new SparkContext(conf)


    val kv1 = sc.parallelize(List(("zhangsan", 11), ("zhangsan", 12), ("lisi", 20), ("wangwu", 32)))
    val kv2 = sc.parallelize(List(("zhangsan", 23), ("zhangsan", 17), ("zhaoliu", 20), ("wangwu", 52)))

    val cogroup = kv1.cogroup(kv2)
    cogroup.foreach(println)


    System.in.read()

  }

}
